//
//  ZYCFliterMultipleChoiceCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/9/9.
//

#import "ZYCFliterMultipleChoiceCell.h"
#import "ZYCRoleTreeModel.h"

@interface ZYCFliterMultipleChoiceCell ()

@property (nonatomic, strong) UIButton *selectButton;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *line;

@end

@implementation ZYCFliterMultipleChoiceCell
- (void)setSelect:(BOOL)select{
    _select = select;
    if (select) {
        [_selectButton setImage:[UIImage imageNamed:@"fxz"] forState:UIControlStateNormal];
    } else {
        [_selectButton setImage:[UIImage imageNamed:@"xzz"] forState:UIControlStateNormal];
    }
}

- (void)setModel:(ZYCRoleTreeModel *)model{
    _model = model;
    _titleLabel.text = model.label;
    if (model.isSelected) {
        [_selectButton setImage:[UIImage imageNamed:@"fxz"] forState:UIControlStateNormal];
    }else{
        [_selectButton setImage:[UIImage imageNamed:@"xzz"] forState:UIControlStateNormal];
    }
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selected = NO;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.selectButton];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.line];

        [self.selectButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15.0f);
            make.centerY.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(13, 13));
        }];

        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(46.0f);
            make.centerY.equalTo(self.contentView);
        }];
        
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15.0f);
            make.right.equalTo(self.contentView).offset(-15.0f);
            make.bottom.equalTo(self.contentView);
            make.height.mas_equalTo(0.5);
        }];
        
    }
    return self;
}

- (UIButton *)selectButton {
    if (!_selectButton) {
        _selectButton = [UIButton buttonWithType:UIButtonTypeCustom];
    }
    return _selectButton;
}


- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 18) titleColor:HEX_RGB(@"333333") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}


- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#DEDEDE");
    }
    return _line;
}

@end
